package com.zhuoyue.web.controller.system;

import com.zhuoyue.common.core.controller.BaseController;
import com.zhuoyue.common.core.domain.AjaxResult;
import com.zhuoyue.common.core.page.TableDataInfo;
import com.zhuoyue.common.utils.poi.ExcelUtil;
import com.zhuoyue.system.domain.po.TblFencingPo;
import com.zhuoyue.system.domain.vo.FencingInfoVo;
import com.zhuoyue.system.service.ITblFencingService;
import com.zhuoyue.web.utils.OrgCodeUtils;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @Author zhanghui
 * @Date: 2021/07/20/9:11
 * @Description: 地理围栏
 */
@RestController
@RequestMapping("/system/geofencing")
public class TblGeoFencingController extends BaseController {
    @Autowired
    private OrgCodeUtils orgCodeUtils;

    @Autowired
    private ITblFencingService tblFencingService;

    @GetMapping("/list")
    @ApiOperation(value = "查询围栏信息")
    public TableDataInfo listFencingInfo(TblFencingPo tblFencingPo, HttpServletRequest request) {
        tblFencingPo.setOrganizationCode(orgCodeUtils.getOrgCode(request));
        startPage();
        List<FencingInfoVo> list = tblFencingService.selectFencingInfoList(tblFencingPo);
        return getDataTable(list);
    }

    @GetMapping("/export")
    public AjaxResult exportFencingInfo(TblFencingPo tblFencingPo, HttpServletRequest request) {
        tblFencingPo.setOrganizationCode(orgCodeUtils.getOrgCode(request));
        tblFencingPo.setPageNum(null);
        tblFencingPo.setPageSize(null);
        List<FencingInfoVo> list = tblFencingService.selectFencingInfoList(tblFencingPo);
        ExcelUtil<FencingInfoVo> util = new ExcelUtil<>(FencingInfoVo.class);
        return util.exportExcel(list, "地理围栏");
    }
}
